#ifndef SJRPASSWORD_CONTEXT_BASIC2_HPP
#define SJRPASSWORD_CONTEXT_BASIC2_HPP

SJR_NAMESPACE_BEGIN

// crypto init
class EpubContextBasic2 : public EpubContextBasic1 {
public:
  explicit EpubContextBasic2(std::string const &path) : EpubContextBasic1(path), mHash() {}

  template<class T>
  std::vector<unsigned char> &hash256(T const *in, int inLen) {
    mResult.clear();
    mHash.init();
    mHash.update(reinterpret_cast<unsigned char *>(const_cast<T *>(in)), inLen);
    auto &&ret = mHash.final();
    mResult.resize(mHash.size());
    memcpy(&mResult[0], ret, mHash.size());
    return mResult;
  }

private:
  EpubSha256 mHash;
  std::vector<unsigned char> mResult;
};

SJR_NAMESPACE_END

#endif//SJRPASSWORD_CONTEXT_BASIC2_HPP
